
export function secondFormate (seconds) {
	let minute,second;
	seconds = Math.abs(seconds)
	minute = Math.floor(seconds / 60);
	minute = minute > 9 ? minute : '0' + minute;
	second = Math.floor(seconds % 60);
	second = second > 9 ? second : '0' + second;
	return `${minute}:${second}`;	
}

export function range(num, min, max) {
  return Math.min(Math.max(num, min), max);
}

export function addNumber(num1, num2) {
  const cardinal = 10 ** 10;
  return Math.round((num1 + num2) * cardinal) / cardinal;
}

export function sizeFormate (size) {
	const per = 1024 * 1024;
	return size >= per ? Number(size / per).toFixed(2) + 'M' : Number(size / 1024).toFixed(2) + 'KB';
}